import java.math.BigDecimal;


public class TesteDouble {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		double d1[] = {1,1.05,0.07,2.943};
		long d2[] = {1,1,7,3};
		double result[] = {2,2.05,7.07,5.943};
		
		for(int i=0; i<d1.length; i++) {
			
			if (arredonda(d1[i]+d2[i]) != arredonda(result[i])) {
				System.out.printf("Erro soma: %s+%s=%s\n",d1[i],d2[i],result[i]);
			}
			if (arredonda((d1[i]*100d)+(d2[i]*100d)) != arredonda((result[i]*100d))) {
				System.out.printf("Erro multipl: %s+%s=%s (soma1=%s) e (soma2=%s)\n",d1[i],d2[i],result[i], arredonda((d1[i]*100d)+(d2[i]*100d)), arredonda((result[i]*100d)));
			}
			
		}
		
	}
	
	public static double arredonda(double valor) {
		
		return Math.round(valor * 100) / 100d;
		
	}

}
